package com.Set集合.TreeSet案例;

import java.util.TreeSet;

public class TreeSetDemoStudent {
/*
Student{name='周冬雨', age=18}
Student{name='马天宇', age=18}
Student{name='黄四郎', age=20}
Student{name='黄四郎替身', age=21}
 */
    public static void main(String[] args) {
        //创建学生类对象
        Student student1 = new Student("周冬雨",18);
        Student student2 = new Student("黄四郎",20);
        Student student3 = new Student("黄四郎替身",21);
        Student student4 = new Student("马天宇",18);

        //创建集合对象
        TreeSet<Student> treeSet = new TreeSet<>();
        treeSet.add(student1);
        treeSet.add(student2);
        treeSet.add(student3);
        treeSet.add(student4);

        for (Student student : treeSet) {
            System.out.println(student);
        }
    }
}
